#Fig_7_8

annual_osv_conflict <- read.csv("annual_osv_conflict.csv")
annual_osv_dyad <- read.csv("annual_osv_dyad.csv")

annual_osv_dyad %>%
  filter(time_period=="1990_to_2021") %>%
  filter(!(conflict_id == 374 & year==1994)) %>%
  ungroup() %>% 
  mutate(outcome = as.factor(outcome) %>%
           fct_recode("Peace Agreement" = "1",
                      "Government Victory" = "3",
                      "Rebel Victory" = "4"),
         government = as.factor(government) %>% 
           fct_recode("Rebel Perpetrated" = "0",
                      "Government Perpetrated" = "1")) %>%
  ggplot(aes(year_count, best_est_osv_annual, color=outcome))+
  geom_smooth(se = F, method = "loess")+
  facet_wrap(~government)+
  #geom_point() +
  xlab("Years Since Termination") + 
  ylab("One-Sided Violence Fatalities") +
  scale_color_discrete(name="Termination Type")+
  coord_cartesian(ylim=c(0,300))+
  theme_bw()

ggsave("Fig7.png", path=imdir, width=6, height = 4, units="in")

annual_osv_conflict %>%
  filter(time_period=="1990_to_2021") %>%
  filter(!(conflict_id == 374 & year==1994)) %>%
  mutate(outcome = as.factor(outcome) %>%
           fct_recode("Peace Agreement" = "1",
                      "Government Victory" = "3",
                      "Rebel Victory" = "4"),
         government = as.factor(government) %>% 
           fct_recode("Rebel Perpetrated" = "0",
                      "Government Perpetrated" = "1")) %>%
  ggplot(aes(year_count, best_est_osv_annual, color=outcome))+
  geom_smooth(se = F, method = "loess")+
  facet_wrap(~government)+
  #geom_point() +
  xlab("Years Since Termination") + 
  ylab("One-Sided Violence Fatalities") +
  scale_color_discrete(name="Termination Type")+
  coord_cartesian(ylim=c(0,300))+
  theme_bw()

ggsave("Fig8.png", path=imdir, width=6, height = 4, units="in")